<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue中的JS动画与velocity.js</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="../../velocity.js"></script>
</head>
<body>
    <div id="app">
        <transition
            name="fade"
            @before-leave="handleBeforeEnter"
            @leave="handleEnter"
            @after-leave="handleAfterEnter"
        >
            <div v-show="show">搞起来</div>
        </transition>
        <button @click="handleClick">toggle</button>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                show: true
            },
            methods: {
                handleClick: function() {
                    this.show = !this.show;
                },
                handleBeforeEnter: function(el) {
                    el.style.opacity = 0;
                },
                handleEnter: function(el, done) {
                    Velocity(el, {opacity: 1}, {duration: 1000, complete: done});
                },
                handleAfterEnter: function(el) {
                    alert(11)
                }
            }
        })
    </script>
</body>
</html>